package com.ithiem.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.dubbo.api.ManagerApi;
import com.itheima.model.domain.Manager;
import com.itheima.model.domain.User;
import com.ithiem.dubbo.mappers.ManagerMapper;
import com.ithiem.dubbo.mappers.UserMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class ManagerApiImpl implements ManagerApi {
    @Autowired
    private ManagerMapper managerMapper;

    @Override
    public Long login(Manager manager) {
        LambdaQueryWrapper<Manager> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Manager::getUsername, manager.getUsername());
        lqw.eq(Manager::getPassword, manager.getPassword());

        Manager manager1 = managerMapper.selectOne(lqw);
        return manager1.getUid();
    }

    @Override
    public Manager findById(Long managerId) {
        Manager manager = managerMapper.selectById(managerId);
        manager.setPassword(null);
        return manager;
    }
}
